﻿@{
    Bundle("jquery_rateit");
    byte valueMin = Svc.Config<Byte>(Par.In("Sales").Of("SellerRatingEntity").Name("Min"));
    byte valueMax = Svc.Config<Byte>(Par.In("Sales").Of("SellerRatingEntity").Name("Max"));
}

<div class="rating">
    @if(Svc.IsAuthenticated || JDM.HasFlags(Model.Flags, "AnonRatingAllowed"))
    {
        <script type="text/javascript">
            jQuery(document).ready(function () {
                jQuery('@ID("#rating")').bind('rated', function() {
                    if(!confirm('@T(Res.In("Common").Of("Expr").Name("WouldYouContinue"))'))
                        jQuery('@ID("#rating")').rateit('value', @JDM.Byte(Model.RatingAverage));
                    else
                        jQuery('@ID("#form")').submit();
                });
            });
        </script>
        <form id="@ID("form")" action="@Url.Action(Loc.Act("Rate").Ctrl("Feedback").Area("Wizard").Localized())" method="post">
            <input type="hidden" name="tgtType" value="seller" />
            <input type="hidden" name="tgtID" value="@JDM.Int32(Model.EntityID)" />
            <input type="range" name="value" id="@ID("value")" value="@JDM.Byte(Model.RatingAverage)" step="1" min="@valueMin" max="@valueMax">
            <div id="@ID("rating")" class="rateit" data-rateit-max="5" data-rateit-resetable="false" data-rateit-backingfld="@ID("#value")"></div>
        </form>
    }
    else
    {
        <div class="rateit" data-rateit-readonly="true" data-rateit-ispreset="false" data-rateit-value="@JDM.Byte(Model.RatingAverage)"></div>
    }
    <p>@T(Res.Name("Text"), JDM.Byte(Model.RatingAverage), JDM.Byte(Model.RatingCount), valueMin, valueMax)</p>
</div>